package com.huage_09.lesson_03;

import java.util.ArrayList;
import java.util.function.Predicate;

public class PredicateTest {
    public static void main(String[] args) {
        ArrayList<String> arr = new ArrayList<String>();
        String[] str = {"张三,23","李四,24","王五,25","张三丰,21","周星驰,18"};

        check(str,arr,s -> s.split(",")[0].length()<3,s -> Integer.parseInt(s.split(",")[1])>24);
        System.out.println(arr);
    }
    public static void check(String[] str, ArrayList<String> arr,Predicate<String> pre1, Predicate<String> pre2){
        for (String s : str){
            boolean b = pre1.and(pre2).test(s);
            if (b){
                arr.add(s);
            }
        }
    }
}
